// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by sidekick. DO NOT EDIT.

pub mod topic_admin {
    use crate::Result;

    /// A builder for [TopicAdmin][crate::client::TopicAdmin].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_pubsub::*;
    /// # use builder::topic_admin::ClientBuilder;
    /// # use client::TopicAdmin;
    /// let builder : ClientBuilder = TopicAdmin::builder();
    /// let client = builder
    ///     .with_endpoint("https://pubsub.googleapis.com")
    ///     .build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub type ClientBuilder =
        gax::client_builder::ClientBuilder<client::Factory, gaxi::options::Credentials>;

    pub(crate) mod client {
        use super::super::super::client::TopicAdmin;
        pub struct Factory;
        impl gax::client_builder::internal::ClientFactory for Factory {
            type Client = TopicAdmin;
            type Credentials = gaxi::options::Credentials;
            async fn build(
                self,
                config: gaxi::options::ClientConfig,
            ) -> gax::client_builder::Result<Self::Client> {
                Self::Client::new(config).await
            }
        }
    }

    /// Common implementation for [crate::client::TopicAdmin] request builders.
    #[derive(Clone, Debug)]
    pub(crate) struct RequestBuilder<R: std::default::Default> {
        stub: std::sync::Arc<dyn super::super::stub::dynamic::TopicAdmin>,
        request: R,
        options: gax::options::RequestOptions,
    }

    impl<R> RequestBuilder<R>
    where
        R: std::default::Default,
    {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::TopicAdmin>,
        ) -> Self {
            Self {
                stub,
                request: R::default(),
                options: gax::options::RequestOptions::default(),
            }
        }
    }

    /// The request builder for [TopicAdmin::create_topic][crate::client::TopicAdmin::create_topic] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_pubsub::builder;
    /// use builder::topic_admin::CreateTopic;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> CreateTopic {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct CreateTopic(RequestBuilder<crate::model::Topic>);

    impl CreateTopic {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::TopicAdmin>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::Topic>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::Topic> {
            (*self.0.stub)
                .create_topic(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][crate::model::Topic::name].
        ///
        /// This is a **required** field for requests.
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }

        /// Sets the value of [labels][crate::model::Topic::labels].
        pub fn set_labels<T, K, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = (K, V)>,
            K: std::convert::Into<std::string::String>,
            V: std::convert::Into<std::string::String>,
        {
            self.0.request.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
            self
        }

        /// Sets the value of [message_storage_policy][crate::model::Topic::message_storage_policy].
        pub fn set_message_storage_policy<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::MessageStoragePolicy>,
        {
            self.0.request.message_storage_policy = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [message_storage_policy][crate::model::Topic::message_storage_policy].
        pub fn set_or_clear_message_storage_policy<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::MessageStoragePolicy>,
        {
            self.0.request.message_storage_policy = v.map(|x| x.into());
            self
        }

        /// Sets the value of [kms_key_name][crate::model::Topic::kms_key_name].
        pub fn set_kms_key_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.kms_key_name = v.into();
            self
        }

        /// Sets the value of [schema_settings][crate::model::Topic::schema_settings].
        pub fn set_schema_settings<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::SchemaSettings>,
        {
            self.0.request.schema_settings = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [schema_settings][crate::model::Topic::schema_settings].
        pub fn set_or_clear_schema_settings<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::SchemaSettings>,
        {
            self.0.request.schema_settings = v.map(|x| x.into());
            self
        }

        /// Sets the value of [satisfies_pzs][crate::model::Topic::satisfies_pzs].
        pub fn set_satisfies_pzs<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.satisfies_pzs = v.into();
            self
        }

        /// Sets the value of [message_retention_duration][crate::model::Topic::message_retention_duration].
        pub fn set_message_retention_duration<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<wkt::Duration>,
        {
            self.0.request.message_retention_duration = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [message_retention_duration][crate::model::Topic::message_retention_duration].
        pub fn set_or_clear_message_retention_duration<T>(
            mut self,
            v: std::option::Option<T>,
        ) -> Self
        where
            T: std::convert::Into<wkt::Duration>,
        {
            self.0.request.message_retention_duration = v.map(|x| x.into());
            self
        }

        /// Sets the value of [state][crate::model::Topic::state].
        pub fn set_state<T: Into<crate::model::topic::State>>(mut self, v: T) -> Self {
            self.0.request.state = v.into();
            self
        }

        /// Sets the value of [ingestion_data_source_settings][crate::model::Topic::ingestion_data_source_settings].
        pub fn set_ingestion_data_source_settings<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::IngestionDataSourceSettings>,
        {
            self.0.request.ingestion_data_source_settings = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [ingestion_data_source_settings][crate::model::Topic::ingestion_data_source_settings].
        pub fn set_or_clear_ingestion_data_source_settings<T>(
            mut self,
            v: std::option::Option<T>,
        ) -> Self
        where
            T: std::convert::Into<crate::model::IngestionDataSourceSettings>,
        {
            self.0.request.ingestion_data_source_settings = v.map(|x| x.into());
            self
        }

        /// Sets the value of [message_transforms][crate::model::Topic::message_transforms].
        pub fn set_message_transforms<T, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = V>,
            V: std::convert::Into<crate::model::MessageTransform>,
        {
            use std::iter::Iterator;
            self.0.request.message_transforms = v.into_iter().map(|i| i.into()).collect();
            self
        }

        /// Sets the value of [tags][crate::model::Topic::tags].
        pub fn set_tags<T, K, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = (K, V)>,
            K: std::convert::Into<std::string::String>,
            V: std::convert::Into<std::string::String>,
        {
            self.0.request.tags = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for CreateTopic {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [TopicAdmin::update_topic][crate::client::TopicAdmin::update_topic] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_pubsub::builder;
    /// use builder::topic_admin::UpdateTopic;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> UpdateTopic {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct UpdateTopic(RequestBuilder<crate::model::UpdateTopicRequest>);

    impl UpdateTopic {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::TopicAdmin>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::UpdateTopicRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::Topic> {
            (*self.0.stub)
                .update_topic(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [topic][crate::model::UpdateTopicRequest::topic].
        ///
        /// This is a **required** field for requests.
        pub fn set_topic<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::Topic>,
        {
            self.0.request.topic = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [topic][crate::model::UpdateTopicRequest::topic].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_topic<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::Topic>,
        {
            self.0.request.topic = v.map(|x| x.into());
            self
        }

        /// Sets the value of [update_mask][crate::model::UpdateTopicRequest::update_mask].
        ///
        /// This is a **required** field for requests.
        pub fn set_update_mask<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<wkt::FieldMask>,
        {
            self.0.request.update_mask = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [update_mask][crate::model::UpdateTopicRequest::update_mask].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<wkt::FieldMask>,
        {
            self.0.request.update_mask = v.map(|x| x.into());
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for UpdateTopic {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [TopicAdmin::get_topic][crate::client::TopicAdmin::get_topic] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_pubsub::builder;
    /// use builder::topic_admin::GetTopic;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetTopic {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetTopic(RequestBuilder<crate::model::GetTopicRequest>);

    impl GetTopic {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::TopicAdmin>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::GetTopicRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::Topic> {
            (*self.0.stub)
                .get_topic(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [topic][crate::model::GetTopicRequest::topic].
        ///
        /// This is a **required** field for requests.
        pub fn set_topic<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.topic = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetTopic {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [TopicAdmin::list_topics][crate::client::TopicAdmin::list_topics] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_pubsub::builder;
    /// use builder::topic_admin::ListTopics;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListTopics {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListTopics(RequestBuilder<crate::model::ListTopicsRequest>);

    impl ListTopics {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::TopicAdmin>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::ListTopicsRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::ListTopicsResponse> {
            (*self.0.stub)
                .list_topics(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<crate::model::ListTopicsResponse, gax::error::Error>
        {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<crate::model::ListTopicsResponse, gax::error::Error>
        {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [project][crate::model::ListTopicsRequest::project].
        ///
        /// This is a **required** field for requests.
        pub fn set_project<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.project = v.into();
            self
        }

        /// Sets the value of [page_size][crate::model::ListTopicsRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }

        /// Sets the value of [page_token][crate::model::ListTopicsRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListTopics {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [TopicAdmin::list_topic_subscriptions][crate::client::TopicAdmin::list_topic_subscriptions] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_pubsub::builder;
    /// use builder::topic_admin::ListTopicSubscriptions;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListTopicSubscriptions {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListTopicSubscriptions(RequestBuilder<crate::model::ListTopicSubscriptionsRequest>);

    impl ListTopicSubscriptions {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::TopicAdmin>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::ListTopicSubscriptionsRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::ListTopicSubscriptionsResponse> {
            (*self.0.stub)
                .list_topic_subscriptions(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [topic][crate::model::ListTopicSubscriptionsRequest::topic].
        ///
        /// This is a **required** field for requests.
        pub fn set_topic<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.topic = v.into();
            self
        }

        /// Sets the value of [page_size][crate::model::ListTopicSubscriptionsRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }

        /// Sets the value of [page_token][crate::model::ListTopicSubscriptionsRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListTopicSubscriptions {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [TopicAdmin::list_topic_snapshots][crate::client::TopicAdmin::list_topic_snapshots] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_pubsub::builder;
    /// use builder::topic_admin::ListTopicSnapshots;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListTopicSnapshots {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListTopicSnapshots(RequestBuilder<crate::model::ListTopicSnapshotsRequest>);

    impl ListTopicSnapshots {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::TopicAdmin>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::ListTopicSnapshotsRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::ListTopicSnapshotsResponse> {
            (*self.0.stub)
                .list_topic_snapshots(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [topic][crate::model::ListTopicSnapshotsRequest::topic].
        ///
        /// This is a **required** field for requests.
        pub fn set_topic<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.topic = v.into();
            self
        }

        /// Sets the value of [page_size][crate::model::ListTopicSnapshotsRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }

        /// Sets the value of [page_token][crate::model::ListTopicSnapshotsRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListTopicSnapshots {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [TopicAdmin::delete_topic][crate::client::TopicAdmin::delete_topic] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_pubsub::builder;
    /// use builder::topic_admin::DeleteTopic;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> DeleteTopic {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct DeleteTopic(RequestBuilder<crate::model::DeleteTopicRequest>);

    impl DeleteTopic {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::TopicAdmin>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::DeleteTopicRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<()> {
            (*self.0.stub)
                .delete_topic(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [topic][crate::model::DeleteTopicRequest::topic].
        ///
        /// This is a **required** field for requests.
        pub fn set_topic<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.topic = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for DeleteTopic {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [TopicAdmin::detach_subscription][crate::client::TopicAdmin::detach_subscription] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_pubsub::builder;
    /// use builder::topic_admin::DetachSubscription;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> DetachSubscription {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct DetachSubscription(RequestBuilder<crate::model::DetachSubscriptionRequest>);

    impl DetachSubscription {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::TopicAdmin>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::DetachSubscriptionRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::DetachSubscriptionResponse> {
            (*self.0.stub)
                .detach_subscription(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [subscription][crate::model::DetachSubscriptionRequest::subscription].
        ///
        /// This is a **required** field for requests.
        pub fn set_subscription<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.subscription = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for DetachSubscription {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }
}

pub mod subscription_admin {
    use crate::Result;

    /// A builder for [SubscriptionAdmin][crate::client::SubscriptionAdmin].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_pubsub::*;
    /// # use builder::subscription_admin::ClientBuilder;
    /// # use client::SubscriptionAdmin;
    /// let builder : ClientBuilder = SubscriptionAdmin::builder();
    /// let client = builder
    ///     .with_endpoint("https://pubsub.googleapis.com")
    ///     .build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub type ClientBuilder =
        gax::client_builder::ClientBuilder<client::Factory, gaxi::options::Credentials>;

    pub(crate) mod client {
        use super::super::super::client::SubscriptionAdmin;
        pub struct Factory;
        impl gax::client_builder::internal::ClientFactory for Factory {
            type Client = SubscriptionAdmin;
            type Credentials = gaxi::options::Credentials;
            async fn build(
                self,
                config: gaxi::options::ClientConfig,
            ) -> gax::client_builder::Result<Self::Client> {
                Self::Client::new(config).await
            }
        }
    }

    /// Common implementation for [crate::client::SubscriptionAdmin] request builders.
    #[derive(Clone, Debug)]
    pub(crate) struct RequestBuilder<R: std::default::Default> {
        stub: std::sync::Arc<dyn super::super::stub::dynamic::SubscriptionAdmin>,
        request: R,
        options: gax::options::RequestOptions,
    }

    impl<R> RequestBuilder<R>
    where
        R: std::default::Default,
    {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SubscriptionAdmin>,
        ) -> Self {
            Self {
                stub,
                request: R::default(),
                options: gax::options::RequestOptions::default(),
            }
        }
    }

    /// The request builder for [SubscriptionAdmin::create_subscription][crate::client::SubscriptionAdmin::create_subscription] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_pubsub::builder;
    /// use builder::subscription_admin::CreateSubscription;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> CreateSubscription {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct CreateSubscription(RequestBuilder<crate::model::Subscription>);

    impl CreateSubscription {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SubscriptionAdmin>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::Subscription>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::Subscription> {
            (*self.0.stub)
                .create_subscription(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][crate::model::Subscription::name].
        ///
        /// This is a **required** field for requests.
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }

        /// Sets the value of [topic][crate::model::Subscription::topic].
        ///
        /// This is a **required** field for requests.
        pub fn set_topic<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.topic = v.into();
            self
        }

        /// Sets the value of [push_config][crate::model::Subscription::push_config].
        pub fn set_push_config<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::PushConfig>,
        {
            self.0.request.push_config = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [push_config][crate::model::Subscription::push_config].
        pub fn set_or_clear_push_config<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::PushConfig>,
        {
            self.0.request.push_config = v.map(|x| x.into());
            self
        }

        /// Sets the value of [bigquery_config][crate::model::Subscription::bigquery_config].
        pub fn set_bigquery_config<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::BigQueryConfig>,
        {
            self.0.request.bigquery_config = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [bigquery_config][crate::model::Subscription::bigquery_config].
        pub fn set_or_clear_bigquery_config<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::BigQueryConfig>,
        {
            self.0.request.bigquery_config = v.map(|x| x.into());
            self
        }

        /// Sets the value of [cloud_storage_config][crate::model::Subscription::cloud_storage_config].
        pub fn set_cloud_storage_config<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::CloudStorageConfig>,
        {
            self.0.request.cloud_storage_config = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [cloud_storage_config][crate::model::Subscription::cloud_storage_config].
        pub fn set_or_clear_cloud_storage_config<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::CloudStorageConfig>,
        {
            self.0.request.cloud_storage_config = v.map(|x| x.into());
            self
        }

        /// Sets the value of [ack_deadline_seconds][crate::model::Subscription::ack_deadline_seconds].
        pub fn set_ack_deadline_seconds<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.ack_deadline_seconds = v.into();
            self
        }

        /// Sets the value of [retain_acked_messages][crate::model::Subscription::retain_acked_messages].
        pub fn set_retain_acked_messages<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.retain_acked_messages = v.into();
            self
        }

        /// Sets the value of [message_retention_duration][crate::model::Subscription::message_retention_duration].
        pub fn set_message_retention_duration<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<wkt::Duration>,
        {
            self.0.request.message_retention_duration = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [message_retention_duration][crate::model::Subscription::message_retention_duration].
        pub fn set_or_clear_message_retention_duration<T>(
            mut self,
            v: std::option::Option<T>,
        ) -> Self
        where
            T: std::convert::Into<wkt::Duration>,
        {
            self.0.request.message_retention_duration = v.map(|x| x.into());
            self
        }

        /// Sets the value of [labels][crate::model::Subscription::labels].
        pub fn set_labels<T, K, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = (K, V)>,
            K: std::convert::Into<std::string::String>,
            V: std::convert::Into<std::string::String>,
        {
            self.0.request.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
            self
        }

        /// Sets the value of [enable_message_ordering][crate::model::Subscription::enable_message_ordering].
        pub fn set_enable_message_ordering<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.enable_message_ordering = v.into();
            self
        }

        /// Sets the value of [expiration_policy][crate::model::Subscription::expiration_policy].
        pub fn set_expiration_policy<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::ExpirationPolicy>,
        {
            self.0.request.expiration_policy = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [expiration_policy][crate::model::Subscription::expiration_policy].
        pub fn set_or_clear_expiration_policy<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::ExpirationPolicy>,
        {
            self.0.request.expiration_policy = v.map(|x| x.into());
            self
        }

        /// Sets the value of [filter][crate::model::Subscription::filter].
        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.filter = v.into();
            self
        }

        /// Sets the value of [dead_letter_policy][crate::model::Subscription::dead_letter_policy].
        pub fn set_dead_letter_policy<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::DeadLetterPolicy>,
        {
            self.0.request.dead_letter_policy = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [dead_letter_policy][crate::model::Subscription::dead_letter_policy].
        pub fn set_or_clear_dead_letter_policy<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::DeadLetterPolicy>,
        {
            self.0.request.dead_letter_policy = v.map(|x| x.into());
            self
        }

        /// Sets the value of [retry_policy][crate::model::Subscription::retry_policy].
        pub fn set_retry_policy<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::RetryPolicy>,
        {
            self.0.request.retry_policy = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [retry_policy][crate::model::Subscription::retry_policy].
        pub fn set_or_clear_retry_policy<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::RetryPolicy>,
        {
            self.0.request.retry_policy = v.map(|x| x.into());
            self
        }

        /// Sets the value of [detached][crate::model::Subscription::detached].
        pub fn set_detached<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.detached = v.into();
            self
        }

        /// Sets the value of [enable_exactly_once_delivery][crate::model::Subscription::enable_exactly_once_delivery].
        pub fn set_enable_exactly_once_delivery<T: Into<bool>>(mut self, v: T) -> Self {
            self.0.request.enable_exactly_once_delivery = v.into();
            self
        }

        /// Sets the value of [topic_message_retention_duration][crate::model::Subscription::topic_message_retention_duration].
        pub fn set_topic_message_retention_duration<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<wkt::Duration>,
        {
            self.0.request.topic_message_retention_duration = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [topic_message_retention_duration][crate::model::Subscription::topic_message_retention_duration].
        pub fn set_or_clear_topic_message_retention_duration<T>(
            mut self,
            v: std::option::Option<T>,
        ) -> Self
        where
            T: std::convert::Into<wkt::Duration>,
        {
            self.0.request.topic_message_retention_duration = v.map(|x| x.into());
            self
        }

        /// Sets the value of [state][crate::model::Subscription::state].
        pub fn set_state<T: Into<crate::model::subscription::State>>(mut self, v: T) -> Self {
            self.0.request.state = v.into();
            self
        }

        /// Sets the value of [analytics_hub_subscription_info][crate::model::Subscription::analytics_hub_subscription_info].
        pub fn set_analytics_hub_subscription_info<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::subscription::AnalyticsHubSubscriptionInfo>,
        {
            self.0.request.analytics_hub_subscription_info = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [analytics_hub_subscription_info][crate::model::Subscription::analytics_hub_subscription_info].
        pub fn set_or_clear_analytics_hub_subscription_info<T>(
            mut self,
            v: std::option::Option<T>,
        ) -> Self
        where
            T: std::convert::Into<crate::model::subscription::AnalyticsHubSubscriptionInfo>,
        {
            self.0.request.analytics_hub_subscription_info = v.map(|x| x.into());
            self
        }

        /// Sets the value of [message_transforms][crate::model::Subscription::message_transforms].
        pub fn set_message_transforms<T, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = V>,
            V: std::convert::Into<crate::model::MessageTransform>,
        {
            use std::iter::Iterator;
            self.0.request.message_transforms = v.into_iter().map(|i| i.into()).collect();
            self
        }

        /// Sets the value of [tags][crate::model::Subscription::tags].
        pub fn set_tags<T, K, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = (K, V)>,
            K: std::convert::Into<std::string::String>,
            V: std::convert::Into<std::string::String>,
        {
            self.0.request.tags = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for CreateSubscription {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [SubscriptionAdmin::get_subscription][crate::client::SubscriptionAdmin::get_subscription] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_pubsub::builder;
    /// use builder::subscription_admin::GetSubscription;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetSubscription {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetSubscription(RequestBuilder<crate::model::GetSubscriptionRequest>);

    impl GetSubscription {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SubscriptionAdmin>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::GetSubscriptionRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::Subscription> {
            (*self.0.stub)
                .get_subscription(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [subscription][crate::model::GetSubscriptionRequest::subscription].
        ///
        /// This is a **required** field for requests.
        pub fn set_subscription<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.subscription = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetSubscription {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [SubscriptionAdmin::update_subscription][crate::client::SubscriptionAdmin::update_subscription] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_pubsub::builder;
    /// use builder::subscription_admin::UpdateSubscription;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> UpdateSubscription {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct UpdateSubscription(RequestBuilder<crate::model::UpdateSubscriptionRequest>);

    impl UpdateSubscription {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SubscriptionAdmin>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::UpdateSubscriptionRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::Subscription> {
            (*self.0.stub)
                .update_subscription(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [subscription][crate::model::UpdateSubscriptionRequest::subscription].
        ///
        /// This is a **required** field for requests.
        pub fn set_subscription<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::Subscription>,
        {
            self.0.request.subscription = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [subscription][crate::model::UpdateSubscriptionRequest::subscription].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_subscription<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::Subscription>,
        {
            self.0.request.subscription = v.map(|x| x.into());
            self
        }

        /// Sets the value of [update_mask][crate::model::UpdateSubscriptionRequest::update_mask].
        ///
        /// This is a **required** field for requests.
        pub fn set_update_mask<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<wkt::FieldMask>,
        {
            self.0.request.update_mask = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [update_mask][crate::model::UpdateSubscriptionRequest::update_mask].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<wkt::FieldMask>,
        {
            self.0.request.update_mask = v.map(|x| x.into());
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for UpdateSubscription {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [SubscriptionAdmin::list_subscriptions][crate::client::SubscriptionAdmin::list_subscriptions] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_pubsub::builder;
    /// use builder::subscription_admin::ListSubscriptions;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListSubscriptions {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListSubscriptions(RequestBuilder<crate::model::ListSubscriptionsRequest>);

    impl ListSubscriptions {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SubscriptionAdmin>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::ListSubscriptionsRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::ListSubscriptionsResponse> {
            (*self.0.stub)
                .list_subscriptions(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<crate::model::ListSubscriptionsResponse, gax::error::Error>
        {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<crate::model::ListSubscriptionsResponse, gax::error::Error>
        {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [project][crate::model::ListSubscriptionsRequest::project].
        ///
        /// This is a **required** field for requests.
        pub fn set_project<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.project = v.into();
            self
        }

        /// Sets the value of [page_size][crate::model::ListSubscriptionsRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }

        /// Sets the value of [page_token][crate::model::ListSubscriptionsRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListSubscriptions {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [SubscriptionAdmin::delete_subscription][crate::client::SubscriptionAdmin::delete_subscription] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_pubsub::builder;
    /// use builder::subscription_admin::DeleteSubscription;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> DeleteSubscription {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct DeleteSubscription(RequestBuilder<crate::model::DeleteSubscriptionRequest>);

    impl DeleteSubscription {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SubscriptionAdmin>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::DeleteSubscriptionRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<()> {
            (*self.0.stub)
                .delete_subscription(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [subscription][crate::model::DeleteSubscriptionRequest::subscription].
        ///
        /// This is a **required** field for requests.
        pub fn set_subscription<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.subscription = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for DeleteSubscription {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [SubscriptionAdmin::modify_push_config][crate::client::SubscriptionAdmin::modify_push_config] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_pubsub::builder;
    /// use builder::subscription_admin::ModifyPushConfig;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ModifyPushConfig {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ModifyPushConfig(RequestBuilder<crate::model::ModifyPushConfigRequest>);

    impl ModifyPushConfig {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SubscriptionAdmin>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::ModifyPushConfigRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<()> {
            (*self.0.stub)
                .modify_push_config(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [subscription][crate::model::ModifyPushConfigRequest::subscription].
        ///
        /// This is a **required** field for requests.
        pub fn set_subscription<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.subscription = v.into();
            self
        }

        /// Sets the value of [push_config][crate::model::ModifyPushConfigRequest::push_config].
        ///
        /// This is a **required** field for requests.
        pub fn set_push_config<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::PushConfig>,
        {
            self.0.request.push_config = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [push_config][crate::model::ModifyPushConfigRequest::push_config].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_push_config<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::PushConfig>,
        {
            self.0.request.push_config = v.map(|x| x.into());
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ModifyPushConfig {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [SubscriptionAdmin::get_snapshot][crate::client::SubscriptionAdmin::get_snapshot] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_pubsub::builder;
    /// use builder::subscription_admin::GetSnapshot;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetSnapshot {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetSnapshot(RequestBuilder<crate::model::GetSnapshotRequest>);

    impl GetSnapshot {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SubscriptionAdmin>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::GetSnapshotRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::Snapshot> {
            (*self.0.stub)
                .get_snapshot(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [snapshot][crate::model::GetSnapshotRequest::snapshot].
        ///
        /// This is a **required** field for requests.
        pub fn set_snapshot<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.snapshot = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetSnapshot {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [SubscriptionAdmin::list_snapshots][crate::client::SubscriptionAdmin::list_snapshots] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_pubsub::builder;
    /// use builder::subscription_admin::ListSnapshots;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListSnapshots {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListSnapshots(RequestBuilder<crate::model::ListSnapshotsRequest>);

    impl ListSnapshots {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SubscriptionAdmin>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::ListSnapshotsRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::ListSnapshotsResponse> {
            (*self.0.stub)
                .list_snapshots(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<crate::model::ListSnapshotsResponse, gax::error::Error>
        {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<crate::model::ListSnapshotsResponse, gax::error::Error>
        {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [project][crate::model::ListSnapshotsRequest::project].
        ///
        /// This is a **required** field for requests.
        pub fn set_project<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.project = v.into();
            self
        }

        /// Sets the value of [page_size][crate::model::ListSnapshotsRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }

        /// Sets the value of [page_token][crate::model::ListSnapshotsRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListSnapshots {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [SubscriptionAdmin::create_snapshot][crate::client::SubscriptionAdmin::create_snapshot] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_pubsub::builder;
    /// use builder::subscription_admin::CreateSnapshot;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> CreateSnapshot {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct CreateSnapshot(RequestBuilder<crate::model::CreateSnapshotRequest>);

    impl CreateSnapshot {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SubscriptionAdmin>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::CreateSnapshotRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::Snapshot> {
            (*self.0.stub)
                .create_snapshot(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][crate::model::CreateSnapshotRequest::name].
        ///
        /// This is a **required** field for requests.
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }

        /// Sets the value of [subscription][crate::model::CreateSnapshotRequest::subscription].
        ///
        /// This is a **required** field for requests.
        pub fn set_subscription<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.subscription = v.into();
            self
        }

        /// Sets the value of [labels][crate::model::CreateSnapshotRequest::labels].
        pub fn set_labels<T, K, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = (K, V)>,
            K: std::convert::Into<std::string::String>,
            V: std::convert::Into<std::string::String>,
        {
            self.0.request.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
            self
        }

        /// Sets the value of [tags][crate::model::CreateSnapshotRequest::tags].
        pub fn set_tags<T, K, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = (K, V)>,
            K: std::convert::Into<std::string::String>,
            V: std::convert::Into<std::string::String>,
        {
            self.0.request.tags = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for CreateSnapshot {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [SubscriptionAdmin::update_snapshot][crate::client::SubscriptionAdmin::update_snapshot] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_pubsub::builder;
    /// use builder::subscription_admin::UpdateSnapshot;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> UpdateSnapshot {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct UpdateSnapshot(RequestBuilder<crate::model::UpdateSnapshotRequest>);

    impl UpdateSnapshot {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SubscriptionAdmin>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::UpdateSnapshotRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::Snapshot> {
            (*self.0.stub)
                .update_snapshot(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [snapshot][crate::model::UpdateSnapshotRequest::snapshot].
        ///
        /// This is a **required** field for requests.
        pub fn set_snapshot<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::Snapshot>,
        {
            self.0.request.snapshot = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [snapshot][crate::model::UpdateSnapshotRequest::snapshot].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_snapshot<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::Snapshot>,
        {
            self.0.request.snapshot = v.map(|x| x.into());
            self
        }

        /// Sets the value of [update_mask][crate::model::UpdateSnapshotRequest::update_mask].
        ///
        /// This is a **required** field for requests.
        pub fn set_update_mask<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<wkt::FieldMask>,
        {
            self.0.request.update_mask = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [update_mask][crate::model::UpdateSnapshotRequest::update_mask].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<wkt::FieldMask>,
        {
            self.0.request.update_mask = v.map(|x| x.into());
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for UpdateSnapshot {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [SubscriptionAdmin::delete_snapshot][crate::client::SubscriptionAdmin::delete_snapshot] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_pubsub::builder;
    /// use builder::subscription_admin::DeleteSnapshot;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> DeleteSnapshot {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct DeleteSnapshot(RequestBuilder<crate::model::DeleteSnapshotRequest>);

    impl DeleteSnapshot {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SubscriptionAdmin>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::DeleteSnapshotRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<()> {
            (*self.0.stub)
                .delete_snapshot(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [snapshot][crate::model::DeleteSnapshotRequest::snapshot].
        ///
        /// This is a **required** field for requests.
        pub fn set_snapshot<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.snapshot = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for DeleteSnapshot {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [SubscriptionAdmin::seek][crate::client::SubscriptionAdmin::seek] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_pubsub::builder;
    /// use builder::subscription_admin::Seek;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> Seek {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct Seek(RequestBuilder<crate::model::SeekRequest>);

    impl Seek {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SubscriptionAdmin>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::SeekRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::SeekResponse> {
            (*self.0.stub)
                .seek(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [subscription][crate::model::SeekRequest::subscription].
        ///
        /// This is a **required** field for requests.
        pub fn set_subscription<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.subscription = v.into();
            self
        }

        /// Sets the value of [target][crate::model::SeekRequest::target].
        ///
        /// Note that all the setters affecting `target` are
        /// mutually exclusive.
        pub fn set_target<T: Into<Option<crate::model::seek_request::Target>>>(
            mut self,
            v: T,
        ) -> Self {
            self.0.request.target = v.into();
            self
        }

        /// Sets the value of [target][crate::model::SeekRequest::target]
        /// to hold a `Time`.
        ///
        /// Note that all the setters affecting `target` are
        /// mutually exclusive.
        pub fn set_time<T: std::convert::Into<std::boxed::Box<wkt::Timestamp>>>(
            mut self,
            v: T,
        ) -> Self {
            self.0.request = self.0.request.set_time(v);
            self
        }

        /// Sets the value of [target][crate::model::SeekRequest::target]
        /// to hold a `Snapshot`.
        ///
        /// Note that all the setters affecting `target` are
        /// mutually exclusive.
        pub fn set_snapshot<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request = self.0.request.set_snapshot(v);
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for Seek {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }
}

pub mod schema_service {
    use crate::Result;

    /// A builder for [SchemaService][crate::client::SchemaService].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_pubsub::*;
    /// # use builder::schema_service::ClientBuilder;
    /// # use client::SchemaService;
    /// let builder : ClientBuilder = SchemaService::builder();
    /// let client = builder
    ///     .with_endpoint("https://pubsub.googleapis.com")
    ///     .build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub type ClientBuilder =
        gax::client_builder::ClientBuilder<client::Factory, gaxi::options::Credentials>;

    pub(crate) mod client {
        use super::super::super::client::SchemaService;
        pub struct Factory;
        impl gax::client_builder::internal::ClientFactory for Factory {
            type Client = SchemaService;
            type Credentials = gaxi::options::Credentials;
            async fn build(
                self,
                config: gaxi::options::ClientConfig,
            ) -> gax::client_builder::Result<Self::Client> {
                Self::Client::new(config).await
            }
        }
    }

    /// Common implementation for [crate::client::SchemaService] request builders.
    #[derive(Clone, Debug)]
    pub(crate) struct RequestBuilder<R: std::default::Default> {
        stub: std::sync::Arc<dyn super::super::stub::dynamic::SchemaService>,
        request: R,
        options: gax::options::RequestOptions,
    }

    impl<R> RequestBuilder<R>
    where
        R: std::default::Default,
    {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SchemaService>,
        ) -> Self {
            Self {
                stub,
                request: R::default(),
                options: gax::options::RequestOptions::default(),
            }
        }
    }

    /// The request builder for [SchemaService::create_schema][crate::client::SchemaService::create_schema] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_pubsub::builder;
    /// use builder::schema_service::CreateSchema;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> CreateSchema {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct CreateSchema(RequestBuilder<crate::model::CreateSchemaRequest>);

    impl CreateSchema {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SchemaService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::CreateSchemaRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::Schema> {
            (*self.0.stub)
                .create_schema(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [parent][crate::model::CreateSchemaRequest::parent].
        ///
        /// This is a **required** field for requests.
        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent = v.into();
            self
        }

        /// Sets the value of [schema][crate::model::CreateSchemaRequest::schema].
        ///
        /// This is a **required** field for requests.
        pub fn set_schema<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::Schema>,
        {
            self.0.request.schema = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [schema][crate::model::CreateSchemaRequest::schema].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_schema<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::Schema>,
        {
            self.0.request.schema = v.map(|x| x.into());
            self
        }

        /// Sets the value of [schema_id][crate::model::CreateSchemaRequest::schema_id].
        pub fn set_schema_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.schema_id = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for CreateSchema {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [SchemaService::get_schema][crate::client::SchemaService::get_schema] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_pubsub::builder;
    /// use builder::schema_service::GetSchema;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetSchema {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetSchema(RequestBuilder<crate::model::GetSchemaRequest>);

    impl GetSchema {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SchemaService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::GetSchemaRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::Schema> {
            (*self.0.stub)
                .get_schema(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][crate::model::GetSchemaRequest::name].
        ///
        /// This is a **required** field for requests.
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }

        /// Sets the value of [view][crate::model::GetSchemaRequest::view].
        pub fn set_view<T: Into<crate::model::SchemaView>>(mut self, v: T) -> Self {
            self.0.request.view = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetSchema {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [SchemaService::list_schemas][crate::client::SchemaService::list_schemas] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_pubsub::builder;
    /// use builder::schema_service::ListSchemas;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListSchemas {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListSchemas(RequestBuilder<crate::model::ListSchemasRequest>);

    impl ListSchemas {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SchemaService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::ListSchemasRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::ListSchemasResponse> {
            (*self.0.stub)
                .list_schemas(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<crate::model::ListSchemasResponse, gax::error::Error>
        {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<crate::model::ListSchemasResponse, gax::error::Error>
        {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [parent][crate::model::ListSchemasRequest::parent].
        ///
        /// This is a **required** field for requests.
        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent = v.into();
            self
        }

        /// Sets the value of [view][crate::model::ListSchemasRequest::view].
        pub fn set_view<T: Into<crate::model::SchemaView>>(mut self, v: T) -> Self {
            self.0.request.view = v.into();
            self
        }

        /// Sets the value of [page_size][crate::model::ListSchemasRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }

        /// Sets the value of [page_token][crate::model::ListSchemasRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListSchemas {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [SchemaService::list_schema_revisions][crate::client::SchemaService::list_schema_revisions] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_pubsub::builder;
    /// use builder::schema_service::ListSchemaRevisions;
    /// # tokio_test::block_on(async {
    /// use gax::paginator::ItemPaginator;
    ///
    /// let builder = prepare_request_builder();
    /// let mut items = builder.by_item();
    /// while let Some(result) = items.next().await {
    ///   let item = result?;
    /// }
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ListSchemaRevisions {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ListSchemaRevisions(RequestBuilder<crate::model::ListSchemaRevisionsRequest>);

    impl ListSchemaRevisions {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SchemaService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::ListSchemaRevisionsRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::ListSchemaRevisionsResponse> {
            (*self.0.stub)
                .list_schema_revisions(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Streams each page in the collection.
        pub fn by_page(
            self,
        ) -> impl gax::paginator::Paginator<crate::model::ListSchemaRevisionsResponse, gax::error::Error>
        {
            use std::clone::Clone;
            let token = self.0.request.page_token.clone();
            let execute = move |token: String| {
                let mut builder = self.clone();
                builder.0.request = builder.0.request.set_page_token(token);
                builder.send()
            };
            gax::paginator::internal::new_paginator(token, execute)
        }

        /// Streams each item in the collection.
        pub fn by_item(
            self,
        ) -> impl gax::paginator::ItemPaginator<
            crate::model::ListSchemaRevisionsResponse,
            gax::error::Error,
        > {
            use gax::paginator::Paginator;
            self.by_page().items()
        }

        /// Sets the value of [name][crate::model::ListSchemaRevisionsRequest::name].
        ///
        /// This is a **required** field for requests.
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }

        /// Sets the value of [view][crate::model::ListSchemaRevisionsRequest::view].
        pub fn set_view<T: Into<crate::model::SchemaView>>(mut self, v: T) -> Self {
            self.0.request.view = v.into();
            self
        }

        /// Sets the value of [page_size][crate::model::ListSchemaRevisionsRequest::page_size].
        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
            self.0.request.page_size = v.into();
            self
        }

        /// Sets the value of [page_token][crate::model::ListSchemaRevisionsRequest::page_token].
        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.page_token = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ListSchemaRevisions {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [SchemaService::commit_schema][crate::client::SchemaService::commit_schema] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_pubsub::builder;
    /// use builder::schema_service::CommitSchema;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> CommitSchema {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct CommitSchema(RequestBuilder<crate::model::CommitSchemaRequest>);

    impl CommitSchema {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SchemaService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::CommitSchemaRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::Schema> {
            (*self.0.stub)
                .commit_schema(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][crate::model::CommitSchemaRequest::name].
        ///
        /// This is a **required** field for requests.
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }

        /// Sets the value of [schema][crate::model::CommitSchemaRequest::schema].
        ///
        /// This is a **required** field for requests.
        pub fn set_schema<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::Schema>,
        {
            self.0.request.schema = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [schema][crate::model::CommitSchemaRequest::schema].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_schema<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::Schema>,
        {
            self.0.request.schema = v.map(|x| x.into());
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for CommitSchema {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [SchemaService::rollback_schema][crate::client::SchemaService::rollback_schema] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_pubsub::builder;
    /// use builder::schema_service::RollbackSchema;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> RollbackSchema {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct RollbackSchema(RequestBuilder<crate::model::RollbackSchemaRequest>);

    impl RollbackSchema {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SchemaService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::RollbackSchemaRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::Schema> {
            (*self.0.stub)
                .rollback_schema(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][crate::model::RollbackSchemaRequest::name].
        ///
        /// This is a **required** field for requests.
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }

        /// Sets the value of [revision_id][crate::model::RollbackSchemaRequest::revision_id].
        ///
        /// This is a **required** field for requests.
        pub fn set_revision_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.revision_id = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for RollbackSchema {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [SchemaService::delete_schema_revision][crate::client::SchemaService::delete_schema_revision] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_pubsub::builder;
    /// use builder::schema_service::DeleteSchemaRevision;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> DeleteSchemaRevision {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct DeleteSchemaRevision(RequestBuilder<crate::model::DeleteSchemaRevisionRequest>);

    impl DeleteSchemaRevision {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SchemaService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::DeleteSchemaRevisionRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::Schema> {
            (*self.0.stub)
                .delete_schema_revision(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][crate::model::DeleteSchemaRevisionRequest::name].
        ///
        /// This is a **required** field for requests.
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }

        /// Sets the value of [revision_id][crate::model::DeleteSchemaRevisionRequest::revision_id].
        #[deprecated]
        pub fn set_revision_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.revision_id = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for DeleteSchemaRevision {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [SchemaService::delete_schema][crate::client::SchemaService::delete_schema] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_pubsub::builder;
    /// use builder::schema_service::DeleteSchema;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> DeleteSchema {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct DeleteSchema(RequestBuilder<crate::model::DeleteSchemaRequest>);

    impl DeleteSchema {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SchemaService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::DeleteSchemaRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<()> {
            (*self.0.stub)
                .delete_schema(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [name][crate::model::DeleteSchemaRequest::name].
        ///
        /// This is a **required** field for requests.
        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.name = v.into();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for DeleteSchema {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [SchemaService::validate_schema][crate::client::SchemaService::validate_schema] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_pubsub::builder;
    /// use builder::schema_service::ValidateSchema;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ValidateSchema {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ValidateSchema(RequestBuilder<crate::model::ValidateSchemaRequest>);

    impl ValidateSchema {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SchemaService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::ValidateSchemaRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::ValidateSchemaResponse> {
            (*self.0.stub)
                .validate_schema(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [parent][crate::model::ValidateSchemaRequest::parent].
        ///
        /// This is a **required** field for requests.
        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent = v.into();
            self
        }

        /// Sets the value of [schema][crate::model::ValidateSchemaRequest::schema].
        ///
        /// This is a **required** field for requests.
        pub fn set_schema<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<crate::model::Schema>,
        {
            self.0.request.schema = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [schema][crate::model::ValidateSchemaRequest::schema].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_schema<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<crate::model::Schema>,
        {
            self.0.request.schema = v.map(|x| x.into());
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ValidateSchema {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [SchemaService::validate_message][crate::client::SchemaService::validate_message] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_pubsub::builder;
    /// use builder::schema_service::ValidateMessage;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> ValidateMessage {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct ValidateMessage(RequestBuilder<crate::model::ValidateMessageRequest>);

    impl ValidateMessage {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SchemaService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<crate::model::ValidateMessageRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<crate::model::ValidateMessageResponse> {
            (*self.0.stub)
                .validate_message(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [parent][crate::model::ValidateMessageRequest::parent].
        ///
        /// This is a **required** field for requests.
        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.parent = v.into();
            self
        }

        /// Sets the value of [message][crate::model::ValidateMessageRequest::message].
        pub fn set_message<T: Into<::bytes::Bytes>>(mut self, v: T) -> Self {
            self.0.request.message = v.into();
            self
        }

        /// Sets the value of [encoding][crate::model::ValidateMessageRequest::encoding].
        pub fn set_encoding<T: Into<crate::model::Encoding>>(mut self, v: T) -> Self {
            self.0.request.encoding = v.into();
            self
        }

        /// Sets the value of [schema_spec][crate::model::ValidateMessageRequest::schema_spec].
        ///
        /// Note that all the setters affecting `schema_spec` are
        /// mutually exclusive.
        pub fn set_schema_spec<
            T: Into<Option<crate::model::validate_message_request::SchemaSpec>>,
        >(
            mut self,
            v: T,
        ) -> Self {
            self.0.request.schema_spec = v.into();
            self
        }

        /// Sets the value of [schema_spec][crate::model::ValidateMessageRequest::schema_spec]
        /// to hold a `Name`.
        ///
        /// Note that all the setters affecting `schema_spec` are
        /// mutually exclusive.
        pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request = self.0.request.set_name(v);
            self
        }

        /// Sets the value of [schema_spec][crate::model::ValidateMessageRequest::schema_spec]
        /// to hold a `Schema`.
        ///
        /// Note that all the setters affecting `schema_spec` are
        /// mutually exclusive.
        pub fn set_schema<T: std::convert::Into<std::boxed::Box<crate::model::Schema>>>(
            mut self,
            v: T,
        ) -> Self {
            self.0.request = self.0.request.set_schema(v);
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for ValidateMessage {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [SchemaService::set_iam_policy][crate::client::SchemaService::set_iam_policy] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_pubsub::builder;
    /// use builder::schema_service::SetIamPolicy;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> SetIamPolicy {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct SetIamPolicy(RequestBuilder<iam_v1::model::SetIamPolicyRequest>);

    impl SetIamPolicy {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SchemaService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<iam_v1::model::SetIamPolicyRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<iam_v1::model::Policy> {
            (*self.0.stub)
                .set_iam_policy(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [resource][iam_v1::model::SetIamPolicyRequest::resource].
        ///
        /// This is a **required** field for requests.
        pub fn set_resource<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.resource = v.into();
            self
        }

        /// Sets the value of [policy][iam_v1::model::SetIamPolicyRequest::policy].
        ///
        /// This is a **required** field for requests.
        pub fn set_policy<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<iam_v1::model::Policy>,
        {
            self.0.request.policy = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [policy][iam_v1::model::SetIamPolicyRequest::policy].
        ///
        /// This is a **required** field for requests.
        pub fn set_or_clear_policy<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<iam_v1::model::Policy>,
        {
            self.0.request.policy = v.map(|x| x.into());
            self
        }

        /// Sets the value of [update_mask][iam_v1::model::SetIamPolicyRequest::update_mask].
        pub fn set_update_mask<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<wkt::FieldMask>,
        {
            self.0.request.update_mask = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [update_mask][iam_v1::model::SetIamPolicyRequest::update_mask].
        pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<wkt::FieldMask>,
        {
            self.0.request.update_mask = v.map(|x| x.into());
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for SetIamPolicy {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [SchemaService::get_iam_policy][crate::client::SchemaService::get_iam_policy] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_pubsub::builder;
    /// use builder::schema_service::GetIamPolicy;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> GetIamPolicy {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct GetIamPolicy(RequestBuilder<iam_v1::model::GetIamPolicyRequest>);

    impl GetIamPolicy {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SchemaService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<iam_v1::model::GetIamPolicyRequest>>(mut self, v: V) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<iam_v1::model::Policy> {
            (*self.0.stub)
                .get_iam_policy(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [resource][iam_v1::model::GetIamPolicyRequest::resource].
        ///
        /// This is a **required** field for requests.
        pub fn set_resource<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.resource = v.into();
            self
        }

        /// Sets the value of [options][iam_v1::model::GetIamPolicyRequest::options].
        pub fn set_options<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<iam_v1::model::GetPolicyOptions>,
        {
            self.0.request.options = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [options][iam_v1::model::GetIamPolicyRequest::options].
        pub fn set_or_clear_options<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<iam_v1::model::GetPolicyOptions>,
        {
            self.0.request.options = v.map(|x| x.into());
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for GetIamPolicy {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }

    /// The request builder for [SchemaService::test_iam_permissions][crate::client::SchemaService::test_iam_permissions] calls.
    ///
    /// # Example
    /// ```no_run
    /// # use google_cloud_pubsub::builder;
    /// use builder::schema_service::TestIamPermissions;
    /// # tokio_test::block_on(async {
    ///
    /// let builder = prepare_request_builder();
    /// let response = builder.send().await?;
    /// # gax::Result::<()>::Ok(()) });
    ///
    /// fn prepare_request_builder() -> TestIamPermissions {
    ///   # panic!();
    ///   // ... details omitted ...
    /// }
    /// ```
    #[derive(Clone, Debug)]
    pub struct TestIamPermissions(RequestBuilder<iam_v1::model::TestIamPermissionsRequest>);

    impl TestIamPermissions {
        pub(crate) fn new(
            stub: std::sync::Arc<dyn super::super::stub::dynamic::SchemaService>,
        ) -> Self {
            Self(RequestBuilder::new(stub))
        }

        /// Sets the full request, replacing any prior values.
        pub fn with_request<V: Into<iam_v1::model::TestIamPermissionsRequest>>(
            mut self,
            v: V,
        ) -> Self {
            self.0.request = v.into();
            self
        }

        /// Sets all the options, replacing any prior values.
        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
            self.0.options = v.into();
            self
        }

        /// Sends the request.
        pub async fn send(self) -> Result<iam_v1::model::TestIamPermissionsResponse> {
            (*self.0.stub)
                .test_iam_permissions(self.0.request, self.0.options)
                .await
                .map(gax::response::Response::into_body)
        }

        /// Sets the value of [resource][iam_v1::model::TestIamPermissionsRequest::resource].
        ///
        /// This is a **required** field for requests.
        pub fn set_resource<T: Into<std::string::String>>(mut self, v: T) -> Self {
            self.0.request.resource = v.into();
            self
        }

        /// Sets the value of [permissions][iam_v1::model::TestIamPermissionsRequest::permissions].
        ///
        /// This is a **required** field for requests.
        pub fn set_permissions<T, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = V>,
            V: std::convert::Into<std::string::String>,
        {
            use std::iter::Iterator;
            self.0.request.permissions = v.into_iter().map(|i| i.into()).collect();
            self
        }
    }

    #[doc(hidden)]
    impl gax::options::internal::RequestBuilder for TestIamPermissions {
        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
            &mut self.0.options
        }
    }
}
